package com.yichat.micro.msghttpservice.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

/**
 * Created by chenmohan on 2019/04/25
 *
 * @description
 */
@Slf4j
@Configuration
@EnableScheduling
public class ScheduleConfig {

    // 给sched用的，默认只有1个，时间太长会阻塞
    @Bean(destroyMethod = "shutdown")
    public Executor taskScheduler() {
        log.info("【STARTING】:: init Spring ScheduleThreadPool ok! current corePoolSize is 2");
        return Executors.newScheduledThreadPool(2);
    }

}
